C++
Null Pointer Dereference
🐞 non-compliance
void foo(int* ptr) {
if (ptr != nullptr) {
*ptr = 42;
} else {
// handle error
}
}
int main() {
int* ptr = nullptr;
foo(ptr);
return 0;
}
✅ compliance
void foo(int* ptr) {
if (ptr != nullptr) {
*ptr = 42;
} else {
// handle error
}
}
int main() {
int i = 0;
int* ptr = &i;
foo(ptr);
return 0;
}